<!DOCTYPE html>
<html>
<head>
    <title>{:C('WEB_NAME')}</title>
    <include file="Pub:style" />
</head>
<body>
<div class="container">
    <form class="form-horizontal" action="__URL__/update" method="post">
        <h4 class="form-signin-heading">添加类目</h4>

        <div class="control-group">
            <label class="control-label" for="name">分类名称</label>
            <div class="controls">
                <input type="text" name="name" value="{$result['name']}">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="pid">上级分类</label>
            <div class="controls">
                <select id="pid" name="pid">
                    <option value="0">顶级分类</option>
                </select>
            </div>
        </div>

        <div class="control-group">
            <div class="controls">
                <input type="hidden" name="id" value="{$result['id']}" />
                <input type="hidden" name="shopid" id="shopid" value="{$Think.session.shopid}" />
                <input type="submit" value="确定">
                <input type="reset" value="重置">
            </div>
        </div>




    </form>
</div>
</body>
<script>
    $(document).ready(function(){
        var shopid = $('#shopid').val();
        $.ajax({
            url: "{:U(GROUP_NAME.'/Public/getGoodsInshopCategoryList')}",
            type:'post',
            dataType:'json',
            data:{shopid:shopid},
            success:function(data){
                if(data.error == 0){
                    data = data.list;
                    var count=data.length;
                    var _str = '';
                    for(j=0;j< count; j++){
                        _str +='<option value="'+data[j].id+'"';
                        if(data[j]['id'] == <?php echo $result['pid'];?>){
                            _str += 'selected="selected"';
                        }
                        _str +='>'+data[j].html+data[j].name+'</option>';
                    }
                    $('#pid').append(_str);
                }
            },
            error:function(){
                $("#tips").text("暂无法获取栏目数据");
                $("#tips").fadeIn(2000);
                $("#tips").fadeOut(2000);
            }
        });
    });
</script>
</html>